<title>活动管理</title>
  
<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>活动管理</cite></a>
  </div>
</div>

<div class="layui-fluid">
    <table id="LAY-sale-manage" lay-filter="LAY-sale-manage"></table>
    <script type="text/html" id="paytypeTpl">
      {{# if(d.paytype == 0){ }}
      <span class="layui-badge layui-bg-orange">卡券模式</span>
      {{# }else{ }}
      <span class="layui-badge layui-bg-blue">纯推广模式</span>
      {{# } }}
    </script>
    <script type="text/html" id="cardTpl">
      {{# var card = JSON.parse(d.card) }}
        {{# if(card.list){ }}
          {{# var cardname=[] }}
          {{# for(let i=0; i<card.list.length; i++){ }}
            {{ cardname[i] = card.list[i].name }}
          {{# } }}
          {{# cardname.join() }}
        {{# }else{ }}
          {{ card.name }}
        {{# } }}
    </script> 
    <script type="text/html" id="statusTpl">
      {{# var date = Date.parse(new Date())/1000 }}
      {{# if(d.endtime+86400 < date){ }}
      <span class="layui-badge layui-bg-black">已结束</span>
      {{# }else{ }}
      <span class="layui-badge layui-bg-green">进行中</span>
      {{# } }}
    </script> 
    <script type="text/html" id="table-sale-oper">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
    <a class="layui-btn layui-btn-xs" lay-event="copy"><i class="layui-icon layui-icon-file"></i>复制</a>
    {{# if(d.paytype == 0){ }}<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="paytype0"><i class="layui-icon layui-icon-username"></i>核销员</a>{{# } }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="tuiguang"><i class="layui-icon layui-icon-release"></i>推广</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs more" lay-event="more" onmouseenter="this.click()"><i class="layui-icon layui-icon-down"></i>更多</a>
    <a class="layui-btn layui-btn-xs layui-hide" lay-event="lqjl" id="lqjl{{d.id}}"><i class="layui-icon layui-icon-username"></i>领券记录</a>
    <a class="layui-btn layui-btn-xs layui-hide" lay-event="cyyh" id="cyyh{{d.id}}"><i class="layui-icon layui-icon-username"></i>参与用户</a>
    <a class="layui-btn layui-btn-xs layui-hide" lay-event="hdsj" id="hdsj{{d.id}}"><i class="layui-icon layui-icon-username"></i>活动数据</a>
    <!-- <div class="btnbox"></div> -->
    </script>
</div>

<ul class="btnbox">
  <li><a href="javascript:;" id="lqjl">领券记录</a></li>
  <li><a href="javascript:;" id="cyyh">参与用户</a></li>
  <li><a href="javascript:;" id="hdsj">活动数据</a></li>
  <li><a href="javascript:;" id="jshd">结束活动</a></li>
</ul>
<style>
  .btnbox{
    min-width: 4em;
    padding: 7px 0;
    background-color: #FFF;
    position: absolute;
    top: 0;
    right: 55px;
    z-index: 9;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    display: none;
  }
  .btnbox li a{
    display: block;
    padding: 7px 15px;
  }
  .btnbox li a:hover{
    background-color: #F5F5F5;
  }
</style>
<script>
layui.use('salemerch', layui.factory('salemerch')).use(['admin', 'salemerch', 'table'], function(){
  var $ = layui.$
  ,admin = layui.admin
  ,view = layui.view
  ,table = layui.table
  ,form = layui.form;

  layui.params = {};
  layui.morehover = false;
  $('.btnbox').mouseenter(function(){
    layui.morehover = true;
  });
  $('.btnbox').mouseleave(function(){
      $('.btnbox').fadeOut();
  });
  $('#lqjl').on('click', function(){
    $('#lqjl'+layui.params.id).click();
  });
  $('#cyyh').on('click', function(){
    $('#cyyh'+layui.params.id).click();
  });
  $('#hdsj').on('click', function(){
    $('#hdsj'+layui.params.id).click();
  });
  $('#jshd').on('click', function(){
    layer.confirm("确定结束活动吗？",function(i) {
        $.post(
            layui.setter.baseUrl+'sale/endsale',
            {id: layui.params.id},
            function(ret){
                var {code,msg,data} = ret;
                layer.msg(msg);
                if(code==0){
                    layui.table.reload('LAY-sale-manage');
                }
            }
        );
    })
  });
  
  $('.layui-btn.layuiadmin-btn-sale').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});
</script>